import axios, { type AxiosRequestConfig } from "axios";
const config:AxiosRequestConfig = {
  baseURL: 'https://127.0.0.1/api/',
  timeout: 1000,
  headers: {'X-Custom-Header': 'foobar'},
  withCredentials: true // 允许发送 cookie
}

const instance = axios.create(config);

const requestConfig = function(config:AxiosRequestConfig){
  // 请求前操作
  const token = localStorage.getItem('auth_token')
  if(token){
    config.headers!.Authorization = `Bearer ${token}`;
  }

  return config 
}